home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Plug-In Power Pack for Netscape Communicator
/
Plug-In Power Pack for Netscape Communicator.iso
/
plugins
/
dataviews
/
dvtools
/
demos
/
dwpdemo
/
dwp_dyn.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-05-08
|
15KB
|
547 lines
#ifndef lint
static char SccsId[]= "@(#)dwp_dyn.c V1.7 3/15/95";
#endif
/*------------------------------------------------------------------
| file name -- dwp_dyn.c
|
| functions Description
| --------- -----------
| HandleDynamics Display the latest data.
| setup_main_window Set up the display deques for the main window.
| setup_ammonia_window Set up the display deques for the ammonia
| subsystem window.
| setup_hp_drum_window Set up the display deques for the high
| pressure drum window.
| setup_lp_drum_window Set up the display deques for the low
| pressure drum window.
| setup_hand_window Set up the display deques for the hand/
| autostation window.
| maindqadd Add the dynamic objects to the main window deque.
| v3dqadd Add the dynamic objects to the valve 3 deque.
| v4dqadd Add the dynamic objects to the valve 4 deque.
| ammoniadqadd Add the dynamic objects to the ammonia subsystem
| window deque.
| v1dqadd Add the dynamic objects to the valve 1 deque.
| v2dqadd Add the dynamic objects to the valve 2 deque.
| hpdrumdqadd Add the dynamic objects to the high pressure
| drum window deque.
| lpdrumdqadd Add the dynamic objects to the low pressure
| drum window deque.
| handdqadd Add the dynamic objects to the hand/autostation
| deque.
| change_valve Turn the valve status on or off.
| reset Reset the hand/autostation values to previously
| defined values.
|-----------------------------------------------------------------*/
#include "std.h"
#include "dvstd.h"
#include "dvtools.h"
#include "VOstd.h"
#include "Tfundecl.h"
#include "dvGR.h"
#include "dwp_vars.h"
#include "dwp_data.h"
#include "VGfundecl.h"
#include "VOfundecl.h"
#include "dwp_fundecl.h"
/***************** Begin Function Declarations *************/
LOCAL ADDRESS maindqadd V_P_((OBJECT obj, char *name, ADDRESS argblock));
LOCAL ADDRESS v3dqadd V_P_((OBJECT obj, char *name, ADDRESS argblock));
LOCAL ADDRESS v4dqadd V_P_((OBJECT obj, char *name, ADDRESS argblock));
LOCAL ADDRESS ammoniadqadd V_P_((OBJECT obj, char *name, ADDRESS argblock));
LOCAL ADDRESS v1dqadd V_P_((OBJECT obj, char *name, ADDRESS argblock));
LOCAL ADDRESS v2dqadd V_P_((OBJECT obj, char *name, ADDRESS argblock));
LOCAL ADDRESS hpdrumdqadd V_P_((OBJECT obj, char *name, ADDRESS argblock));
LOCAL ADDRESS lpdrumdqadd V_P_((OBJECT obj, char *name, ADDRESS argblock));
LOCAL ADDRESS handdqadd V_P_((OBJECT obj, char *name, ADDRESS argblock));
/***************** End Function Declarations *************/
/*-----------------------------------------------------------------
|
| HandleDynamics
| Performs the functions needed to update the display to
| reflect the latest data.
*/
void HandleDynamics
V_P_ ((void))
{
INT i;
/* If we are in the middle of opening a window, don't do anything.
|
| This HandleDynamics() routine is called from a TimeOutProc...
| which could get triggered when we call TscOpenSet with
| V_EXPOSURE_BLOCK set to YES. TscOpen will dispatch all events
| while its waiting for the EXPOSE_EVENT and this timeout would get
| called. To avoid "re-entering" the DataViews code, just return
| under this condition.
*/
if (WaitingForExpose == YES)
return;
/* set the high high and low low values */
hihi = highvalue + 10;
lolo = lowvalue - 10;
/* set the alarm status */
if (setpoint < lowvalue)
alarm_status = ALARM_LOW;
else if (setpoint > highvalue)
alarm_status = ALARM_HIGH;
else
alarm_status = ALARM_NORMAL;
/* update the dynamic objects */
for (i = 0; i < MAXWINS; i++)
{
if (window_status[i] == OPEN)
{
if (dynamic_status[i] == ON)
{
INT size, j;
TscSetCurrentScreen (DVscreen[i]);
TdlReadData (dsl[i]);
/*
TdpDrawNext( drawport[i] );
*/
size = VOdqSize (displaydq[i]);
for (j = 1; j <= size; j++)
{
TdpDrawNextObject (drawport[i], VOdqGetEntry (displaydq[i], j));
}
}
}
}
}
/*--------------------------------------------------------------------
|
| setup_main_window
| Set up the display deques for the main window.
*/
void setup_main_window
V_P_ ((void))
{
maindq = VOdqCreate ((int)NULL);
v3dq = VOdqCreate ((int)NULL);
v4dq = VOdqCreate ((int)NULL);
displaydq[MAIN] = VOdqCreate ((int)NULL);
/* put all the dynamic objects into the correct deque */
TdrForEachNamedObject (drawing[MAIN], maindqadd, NULL);
VOdqAddDq (displaydq[MAIN], TOP, maindq);
/* put the valve 3 dynamic objects into the valve 3 deque */
if (v3status == ON)
{
TdrForEachNamedObject (drawing[MAIN], v3dqadd, NULL);
VOdqAddDq (displaydq[MAIN], TOP, v3dq);
}
/* put the valve 4 dynamic objects into the valve 4 deque */
if (v4status == ON)
{
TdrForEachNamedObject (drawing[MAIN], v4dqadd, NULL);
VOdqAddDq (displaydq[MAIN], TOP, v4dq);
}
v3rotate = current_setpoint[3];
v4rotate = current_setpoint[4];
}
/*---------------------------------------------------------------
|
| maindqadd
| Add the main window dynamic objects which do not go
| in the valve 3 or valve 4 deque.
*/
/* ARGSUSED */
LOCAL ADDRESS
maindqadd (obj, name, argblock)
OBJECT obj;
char *name;
ADDRESS argblock;
{
if (strcmp (name, "dyn") == 0)
VOdqAdd (maindq, TOP, obj);
else if (strcmp (name, "W:Valve3") == 0)
VOdqAdd (maindq, TOP, obj);
else if (strcmp (name, "W:Valve4") == 0)
VOdqAdd (maindq, TOP, obj);
return (V_CONTINUE_TRAVERSAL);
}
/*---------------------------------------------------------------
|
| v3dqadd
| Add the main window dynamic objects which are controlled
| by valve 3.
*/
/* ARGSUSED */
LOCAL ADDRESS
v3dqadd (obj, name, argblock)
OBJECT obj;
char *name;
ADDRESS argblock;
{
if (strcmp (name, "v3flow") == 0)
VOdqAdd (v3dq, TOP, obj);
else if (strcmp (name, "W:hp_drum_detail") == 0)
VOdqAdd (v3dq, TOP, obj);
return (V_CONTINUE_TRAVERSAL);
}
/*---------------------------------------------------------------
|
| v4dqadd
| Add the main window dynamic objects which are controlled
| by valve 4.
*/
/* ARGSUSED */
LOCAL ADDRESS
v4dqadd (obj, name, argblock)
OBJECT obj;
char *name;
ADDRESS argblock;
{
if (strcmp (name, "v4flow") == 0)
VOdqAdd (v4dq, TOP, obj);
else if (strcmp (name, "W:lp_drum_detail") == 0)
VOdqAdd (v4dq, TOP, obj);
return (V_CONTINUE_TRAVERSAL);
}
/*--------------------------------------------------------------------
|
| setup_ammonia_window
| Set up the display deques for the ammonia subsystem window.
*/
void setup_ammonia_window
V_P_ ((void))
{
v1dq = VOdqCreate ((int)NULL);
v2dq = VOdqCreate ((int)NULL);
displaydq[AMMONIA] = VOdqCreate ((int)NULL);
TdrForEachNamedObject (drawing[AMMONIA], ammoniadqadd, NULL);
/* put the valve 1 dynamic objects into the valve 1 deque */
if (v1status == ON)
{
TdrForEachNamedObject (drawing[AMMONIA], v1dqadd, NULL);
VOdqAddDq (displaydq[AMMONIA], TOP, v1dq);
}
/* put the valve 2 dynamic objects into the valve 2 deque */
if (v2status == ON)
{
TdrForEachNamedObject (drawing[AMMONIA], v2dqadd, NULL);
VOdqAddDq (displaydq[AMMONIA], TOP, v2dq);
}
v1rotate = current_setpoint[1];
v2rotate = current_setpoint[2];
}
/*---------------------------------------------------------------
|
| ammoniadqadd
| Add the ammonia subsystem window dynamic objects which do not go
| in the valve 1 or valve 2 deque.
*/
/* ARGSUSED */
LOCAL ADDRESS
ammoniadqadd (obj, name, argblock)
OBJECT obj;
char *name;
ADDRESS argblock;
{
if (strcmp (name, "W:Valve1") == 0)
VOdqAdd (displaydq[AMMONIA], TOP, obj);
else if (strcmp (name, "W:Valve2") == 0)
VOdqAdd (displaydq[AMMONIA], TOP, obj);
return (V_CONTINUE_TRAVERSAL);
}
/*---------------------------------------------------------------
|
| v1dqadd
| Add the ammonia subsystem window dynamic objects which
| are controlled by valve 1.
*/
/* ARGSUSED */
LOCAL ADDRESS
v1dqadd (obj, name, argblock)
OBJECT obj;
char *name;
ADDRESS argblock;
{
if (strcmp (name, "v1flow") == 0)
VOdqAdd (v1dq, TOP, obj);
return (V_CONTINUE_TRAVERSAL);
}
/*---------------------------------------------------------------
|
| v2dqadd
| Add the ammonia subsystem window dynamic objects which
| are controlled by valve 2.
*/
/* ARGSUSED */
LOCAL ADDRESS
v2dqadd (obj, name, argblock)
OBJECT obj;
char *name;
ADDRESS argblock;
{
if (strcmp (name, "v2flow") == 0)
VOdqAdd (v2dq, TOP, obj);
return (V_CONTINUE_TRAVERSAL);
}
/*--------------------------------------------------------------------
|
| setup_hp_drum_window
| Set up the display deques for the high pressure drum window.
*/
void setup_hp_drum_window
V_P_ ((void))
{
displaydq[HP_DRUM] = VOdqCreate ((int)NULL);
TdrForEachNamedObject (drawing[HP_DRUM], hpdrumdqadd, NULL);
}
/*---------------------------------------------------------------
|
| hpdrumdqadd
| Add the high pressure drum window dynamic objects to the
| dynamic deque.
*/
/* ARGSUSED */
LOCAL ADDRESS
hpdrumdqadd (obj, name, argblock)
OBJECT obj;
char *name;
ADDRESS argblock;
{
if (strcmp (name, "dyn") == 0)
{
VOdqAdd (displaydq[HP_DRUM], TOP, obj);
}
return (V_CONTINUE_TRAVERSAL);
}
/*--------------------------------------------------------------------
|
| setup_lp_drum_window
| Set up the display deques for the low pressure drum window.
*/
void setup_lp_drum_window
V_P_ ((void))
{
displaydq[LP_DRUM] = VOdqCreate ((int)NULL);
TdrForEachNamedObject (drawing[LP_DRUM], lpdrumdqadd, NULL);
}
/*---------------------------------------------------------------
|
| lpdrumdqadd
| Add the low pressure drum window dynamic objects to the
| dynamic deque.
*/
/* ARGSUSED */
LOCAL ADDRESS
lpdrumdqadd (obj, name, argblock)
OBJECT obj;
char *name;
ADDRESS argblock;
{
if (strcmp (name, "dyn") == 0)
{
VOdqAdd (displaydq[LP_DRUM], TOP, obj);
}
return (V_CONTINUE_TRAVERSAL);
}
/*--------------------------------------------------------------------
|
| setup_hand_window
| Set up the display deques for the hand/autostation window.
*/
void setup_hand_window
V_P_ ((void))
{
displaydq[HAND] = VOdqCreate ((int)NULL);
TdrForEachNamedObject (drawing[HAND], handdqadd, NULL);
setpoint = current_setpoint[whichvalve];
highvalue = current_highvalue[whichvalve];
hihi = highvalue + 10;
lowvalue = current_lowvalue[whichvalve];
lolo = lowvalue - 10;
valvenumber = (FLOAT) whichvalve;
}
/*---------------------------------------------------------------
|
| handdqadd
| Add the hand/autostation window dynamic objects to the
| dynamic deque.
*/
/* ARGSUSED */
LOCAL ADDRESS
handdqadd (obj, name, argblock)
OBJECT obj;
char *name;
ADDRESS argblock;
{
if (strcmp (name, "dyn") == 0)
{
VOdqAdd (displaydq[HAND], TOP, obj);
}
return (V_CONTINUE_TRAVERSAL);
}
/*---------------------------------------------------------------
|
| change_valve
| For the selected valve check the values which indicate
| if the valve needs to be turned on or off and take the
| appropriate action.
*/
void change_valve
V_P_ ((void))
{
current_setpoint[whichvalve] = setpoint;
current_highvalue[whichvalve] = highvalue;
current_lowvalue[whichvalve] = lowvalue;
hihi = highvalue + 10;
lolo = lowvalue - 10;
switch (whichvalve)
{
case 1:
{
/* turn the flow on */
if ((v1status == OFF) && (setpoint >= MINFLOW))
{
TdrForEachNamedObject (drawing[AMMONIA], v1dqadd, NULL);
VOdqAddDq (displaydq[AMMONIA], TOP, v1dq);
v1status = ON;
}
/* turn the flow off */
else if ((v1status == ON) && (setpoint < MINFLOW))
{
VOdqDeleteDq (displaydq[AMMONIA], v1dq);
v1status = OFF;
}
v1rotate = setpoint;
break;
}
case 2:
{
/* turn the flow on */
if ((v2status == OFF) && (setpoint >= MINFLOW))
{
TdrForEachNamedObject (drawing[AMMONIA], v2dqadd, NULL);
VOdqAddDq (displaydq[AMMONIA], TOP, v2dq);
v2status = ON;
}
/* turn the flow off */
else if ((v2status == ON) && (setpoint < MINFLOW))
{
VOdqDeleteDq (displaydq[AMMONIA], v2dq);
v2status = OFF;
}
v2rotate = setpoint;
break;
}
case 3:
{
/* turn the flow on */
if ((v3status == OFF) && (setpoint >= MINFLOW))
{
TdrForEachNamedObject (drawing[MAIN], v3dqadd, NULL);
VOdqAddDq (displaydq[MAIN], TOP, v3dq);
v3status = ON;
}
/* turn the flow off */
else if ((v3status == ON) && (setpoint < MINFLOW))
{
VOdqDeleteDq (displaydq[MAIN], v3dq);
v3status = OFF;
}
v3rotate = setpoint;
break;
}
case 4:
{
/* turn the flow on */
if ((v4status == OFF) && (setpoint >= MINFLOW))
{
TdrForEachNamedObject (drawing[MAIN], v4dqadd, NULL);
VOdqAddDq (displaydq[MAIN], TOP, v4dq);
v4status = ON;
}
/* turn the flow off */
else if ((v4status == ON) && (setpoint < MINFLOW))
{
VOdqDeleteDq (displaydq[MAIN], v4dq);
v4status = OFF;
}
v4rotate = setpoint;
break;
}
}
}
/*-----------------------------------------------------------------
|
| reset
| Reset the hand/autostation values to their previously
| confirmed values.
*/
void reset
V_P_ ((void))
{
setpoint = current_setpoint[whichvalve];
highvalue = current_highvalue[whichvalve];
lowvalue = current_lowvalue[whichvalve];
hihi = highvalue + 10;
lolo = lowvalue - 10;
}